package jm.nj.day10.demo02;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

/*
* 复制文件:一次读一个字符数组复制文件
*
* 把Demo01.java复制到cp2.txt
*
* 创建两个对象
* fr  fw
* 一边读 一边写一边刷
* close
* */
public class Demo04 {
    public static void main(String[] args) throws IOException {
        FileReader fr = new FileReader("Demo01.java");
        FileWriter fw = new FileWriter("cp2.txt");

        char[] chs = new char[1024];
        int len;
        while((len = fr.read(chs)) != -1){
            fw.write(new String(chs,0,len));
            //fw.flush();
        }

        fr.close();
        fw.close();
    }
}
